package com.hmall.common.mq.handler;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessagePostProcessor;

/**
 * @author Administrator
 * @version 1.0
 * @description: TODO
 * @date 2024/6/11 15:31
 */
@NoArgsConstructor
@AllArgsConstructor
public class DelayMsgMessagePostProcessor implements MessagePostProcessor {
    /**
     * 消息延时时间
     */
    private Integer delayTime;
    /**
     * 自定义消息后置处理器逻辑
     *
     * @param message the message.
     * @return the message.
     * @throws AmqpException an exception.
     */
    @Override
    public Message postProcessMessage(Message message) throws AmqpException {
        message.getMessageProperties().setDelay(delayTime);
        return message;
    }
}
